package com.celesea.auth.position.vo;

import com.celesea.auth.position.entity.PositionUser;
import com.celesea.auth.position.v1.controller.request.UserPositionRequest;
import com.celesea.framework.vo.DictionaryVo;

/**
 * @author JackYuan
 * @create 2017-11-24 18:53
 */
public class UserPositionVo {
    private String id;
    private String positionId;
    private String positionName;
    private Byte extend;
    private DictionaryVo user;
    private DictionaryVo dept;

    public UserPositionVo() {
        super();
    }

    public UserPositionVo(PositionUser item) {
        this.id = item.getId();
        this.setPositionId(item.getPositionId());
        this.setPositionName(item.getPositionName());
        this.setExtend(item.getExtend());

        DictionaryVo dept = new DictionaryVo(item.getDeptId(), item.getDeptName());
        this.setDept(dept);

        DictionaryVo user = new DictionaryVo(item.getUserId(), item.getUserName());
        this.setUser(user);
    }

    public UserPositionVo(PositionVo positionVo, UserPositionRequest item) {
        this.user = item.getUser();
        this.dept = item.getDept();
        this.id = item.getId();
        this.setPositionId(positionVo.getId());
        this.setPositionName(positionVo.getName());
        this.extend = item.getExtend();
    }

    public PositionUser toEntity() {
        PositionUser entity = new PositionUser();
        entity.setId(this.getId());
        entity.setUserId(this.getUser().getId());
        entity.setUserName(this.getUser().getName());
        entity.setDeptId(this.getDept().getId());
        entity.setDeptName(this.getDept().getName());
        entity.setPositionId(this.getPositionId());
        entity.setPositionName(this.getPositionName());
        entity.setExtend(this.getExtend());
        return entity;
    }

    public DictionaryVo getUser() {
        return user;
    }

    public void setUser(DictionaryVo user) {
        this.user = user;
    }

    public DictionaryVo getDept() {
        return dept;
    }

    public void setDept(DictionaryVo dept) {
        this.dept = dept;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPositionId() {
        return positionId;
    }

    public void setPositionId(String positionId) {
        this.positionId = positionId;
    }

    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public Byte getExtend() {
        return extend;
    }

    public void setExtend(Byte extend) {
        this.extend = extend;
    }
}
